package org.zch.common.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 时间相关工具类*/
public class TimerSetUtils {

    //判断是不是昨天
    public static boolean isYesterday(Date data) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            //给定日期
            String oldTime = sdf.format(data);
            //当天日期
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -1);
            Date yesterday = calendar.getTime();
            String nowTime = sdf.format(yesterday);

            return oldTime.equals(nowTime);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
